//
//  ViewController.m
//  UI08_界面传值
//
//  Created by wyx on 16/3/18.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"

@interface ViewController ()
@property (nonatomic,retain)UITextField *text1;
@property (nonatomic,retain)UIButton *button;
@property (nonatomic,retain)UILabel *label1;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createSubView];
    [self configForNavigationItem];
}
#pragma mark - 知识点一:通过属性进行界面传值
- (void)passValueByMemoryProperty{
    
}
-(void)createSubView{
    self.text1 = [[UITextField alloc] initWithFrame:CGRectMake(50, 100, 320, 40)];
    self.text1.placeholder = @"请输入用户名 在第二页显示";
    self.text1.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.text1];
    [self.text1 release];
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame = CGRectMake(50, 200, self.view.frame.size.width - 100, 40);
    self.button.backgroundColor = [UIColor yellowColor];
    [self.button setTitle:@"Next" forState:UIControlStateNormal];
    [self.button addTarget:self action:@selector(handleNext:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.button];
    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(50, 300, self.view.frame.size.width - 100, 40)];
    self.label1.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.label1];
    [_label1 release];
    
}
- (void)configForNavigationItem{
    //中间title
    self.navigationItem.title = @"首页";
}
-(void)handleNext:(UIBarButtonItem *)next {
    //创建下一个页面对象
    SecondViewController *second = [[SecondViewController alloc] init];
    //属性赋值
    second.content = self.text1.text;
    //指定当前对象代理人
    second.secondDeledate = self; 
    //navigation 推出新界面
    [self.navigationController pushViewController:second animated:YES];
    [second release];
}
-(void)changeValue:(NSString *)name{
    self.label1.text = name;
}
#pragma mark - 知识点二:通过 delegate 进行界面传值

#pragma mark - 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
